#include "AbstractZigbusConnection.h"
#include <QDebug>


AbstractZigbusConnection::AbstractZigbusConnection(QObject* parent)
    : QObject(parent)
{
    qRegisterMetaType<ZigbusMessage>("ZigbusMessage");
}

void AbstractZigbusConnection::processMessage(const QString &data)
{
    qDebug() << "process data "<<data;
    bool ok = false;
    ZigbusMessage message = ZigbusMessage::createMessage(data, &ok);
    if(!ok || !message.isValid()) {
        qDebug() << "[zigbus] WARNING: invalid message received: " << data;
        return;
    }
    qDebug() << "[zigbus] message received:";
    qDebug() << message.toString();
    emit messageReceived(message);
}
